{%load loader_tags %}{% extends 'base/base.html' %}
{% load i18n %}

{% block inpage_title %}{% trans "Message List" %}{% endblock %}

{% block headercontent %}
<link href="{{ MEDIA_URL }}css/message_list.css" rel="stylesheet" type="text/css"></link>
{% endblock %}

{% block extra_menus %}
<a href="{% url 'folder_list' %}">{% trans "Folder List" %}</a>&nbsp;&nbsp;
<a href="{% url 'mailapp_send_message' %}">{% trans "New Message" %}</a>&nbsp;&nbsp;
{% endblock %}


{% block contents %}
<h2>{{ folder }}</h2>

<div class="filter_list">
<table>
    <tr>
        <th>{% trans "Tags:" %}</th><td>
{% for flag in folder.flags.keywords %}
    <a href="{% url 'message_list' folder.url %}?flag={{ flag }}">{{ flag }}</a>
{% endfor %} </td>
        <th colspan="2"><a href="{% url 'message_list' folder.url %}">{% trans "No Filter"%}</a></th>
    </tr>
</table>
</div>

{% if folder.have_messages %}

<form method="post" action="{% url 'message_list' folder.url %}">

<div class="message_actions">
{{ form.action }}
<input type="submit" name="apply" value="{% trans "Apply" %}"> |
{{ form.folder }}
<input type="submit" name="move" value="{% trans "Move" %}">
<input type="submit" name="copy" value="{% trans "Copy" %}"> |
</div>

{% include "mail/inc_page_nav.html" %}

<div class="message_list">
{% for message in folder %}
    <div class="{% cycle 'row_a' 'row_b' %}">
    <div class="message">
    <div class="date">{{ message.envelope.env_date|date:"Y.m.d H:i" }}</div>
    <div class={% if message.seen %}"seen"{% else %}"not_seen"{% endif %}>
    {% if message.deleted %}<div class="deleted">{% endif %}
    <p><input type="checkbox" name="messages" value="{{message.uid }}">
       <a href="{% url 'mailapp-message' folder=folder.url uid=message.uid %}">
        {% if message.envelope.env_subject %}{{ message.envelope.env_subject }}
        {% else %}{% trans "(No subject)" %}{% endif %}</a></p>
    </div>
    {% if message.deleted %}</div>{% endif %}
    <div class="date">{% trans "Size" %}: {{ message.size|filesizeformat }}</div>
    <p>{% trans "From" %}: {{ message.envelope.from_short|join:", " }}</p>
    <p>{% trans "To" %}: {{ message.envelope.to_short|join:", " }}</p>
    </div>
    </div>
{% endfor %}

</div>
{% include "mail/inc_page_nav.html" %}

<p>{% trans "This will delete PERMANENTLY the messages marked 'delete': " %}
<input type="submit" name="expunge" value="{% trans "Expunge" %}" />
</form>
{% else %}<p>{% trans "Sorry. There are no messages on the current folder." %} - ({{ folder }}){% endif %}
{% endblock %}
